#include "messagebox.h"
#include <QKeyEvent>

MessageBox::MessageBox(QWidget *parent) :
    QTextBrowser(parent)
{
    this->setReadOnly(false);
    this->setMinimumHeight(50);
    this->setMaximumHeight(50);
}


void MessageBox::keyReleaseEvent(QKeyEvent *ev)
{
    if(ev->key() == Qt::Key_Return||ev->key() == Qt::Key_Enter)
    {
        ev->ignore();
        emit returnPressed();
    }
}

void MessageBox::keyPressEvent(QKeyEvent *ev)
{

        if(ev->key() == Qt::Key_Return||ev->key()==Qt::Key_Enter)
        {
            ev->ignore();
        }
        else
            QTextBrowser::keyPressEvent(ev);


}

QString MessageBox::text()
{
    return this->toPlainText();
}
